import {getAgentInfo} from '@/apis/modules/home.js';

const home = {
	namespaced: true,
	state: {
		agentInfo: {
		}
	},
	mutations: {
		save(state, {field, payload}) {
		  if (Object.prototype.toString.call(payload) === '[object Object]') {
			state[field] = { ...state[field], ...payload }
		  } else {
			state[field] = payload
		  }
		}
	},
	actions: {
		async getAgentInfo({ commit }, payload) {
			// const res = await getAgentInfo()
			// console.log(res)
			const {msg, data} = await getAgentInfo()
			console.log(data)
			commit('save', {field: 'agentInfo', payload: data || {}})
		},
	}
}

export default home